package com.fenxiangtech.mall.service.impl;

import com.fenxiangtech.mall.service.UserTokenService;
import com.fenxiangtech.mall.dao.UserDao;
import com.fenxiangtech.mall.entity.User;
import com.fenxiangtech.mall.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private UserTokenService userTokenService;

    @Override
    public boolean updateUser(User user) {
        Long uid = userTokenService.getCurrentUID();
        user.setId(uid);
        user.setUpdateTime(new Date().getTime());
        int count = userDao.updateUser(user);
        return count > 0;
    }
}
